<#assign packageModel=projPackage.entity valuePrefix="#{"
        serviceFullPackage=projPackage.projPackage+"."+projPackage.service
        daoFullPackage=projPackage.projPackage+"." + projPackage.dao + "." +tableInfo.modelClassName+"Mapper"
        modelFullPackage=projPackage.projPackage+"." + projPackage.entity + "." +tableInfo.modelClassName
        utilsFullPackage=projPackage.projPackage + "." + projPackage.utils
        >
package ${serviceFullPackage};

import java.util.List;
import java.util.Optional;
import ${modelFullPackage};
import ${utilsFullPackage}.Example;
import ${utilsFullPackage}.BusinessException;

/**
 * 版本号：20240401
 * @Description : 服务层接口，注意自定义代码写在最后，不要插在中间
 * @Author : chanchaw
 * @Date : ${.now?date} ${.now?time}
 */
public interface ${tableInfo.modelClassName}Service {
    ${tableInfo.modelClassName} insert(${tableInfo.modelClassName} record);
    ${tableInfo.modelClassName} insertSelective(${tableInfo.modelClassName} record);
    List<${tableInfo.modelClassName}> multiInsert(List<${tableInfo.modelClassName}> list);
    int updateByPrimaryKey(${tableInfo.modelClassName} record);
    int updateByPrimaryKeySelective(${tableInfo.modelClassName} record);
    <#list tableInfo.fieldInfoList as field>
    <#if field.primaryKey=true>
    // 根据主键删除
    int deleteByPrimaryKey(${field.javaType} ${field.fieldName});
    // 根据主键查询
    ${tableInfo.modelClassName} selectByPrimaryKey(${field.javaType} ${field.fieldName});
    </#if>
    </#list>
    List<${tableInfo.modelClassName}> selectAll();
    ${tableInfo.modelClassName} save(${tableInfo.modelClassName} record);
    List<${tableInfo.modelClassName}> multiSave(List<${tableInfo.modelClassName}> list);
    ${tableInfo.modelClassName} selectBySid(String sid);
    Boolean exists(String sid);
    //================= 下面是默认方法 ==================
    default void checkEntityNotNull(${tableInfo.modelClassName} record){// 返回true表示合法，可继续
        if(record == null) throw new BusinessException("无法保存空数据！");
    }

    default void checkSidNotEmpty(${tableInfo.modelClassName} record){// 返回true表示合法，可继续
        checkEntityNotNull(record);
        String sid = Optional.ofNullable(record.getSid()).orElse("");
        if(sid.length() == 0) throw new BusinessException("编号不可为空！");
    }

    default ${tableInfo.modelClassName} fullFill(${tableInfo.modelClassName} record){
        return record;
    }

    default void doBeforeInsert(${tableInfo.modelClassName} record){}
    default void doAfterInsert(${tableInfo.modelClassName} record){}
    List<${tableInfo.modelClassName}> selectByExample(Example<${tableInfo.modelClassName}> example);
    default void check4Insert(${tableInfo.modelClassName} record){
        checkSidNotEmpty(record);
        if(exists(record.getSid())) throw new BusinessException("编号" + record.getSid() + "已经存在，请更换后再次保存！");
    }
    //=================以上是自动生成的代码，自定义代码请写在下面==================
}